Skip to content

Use correct BASE_URL for the API by default#3804

Merged
AetherUnbound merged 1 commit intomainfrom
fix/base-url
Feb 20, 2024
Merged

Use correct BASE_URL for the API by default#3804
AetherUnbound merged 1 commit intomainfrom
fix/base-url

Conversation

@AetherUnbound
Copy link
Copy Markdown
Collaborator

Fixes

Fixes #2689 by @AetherUnbound

Description

This PR updates the default value for BASE_URL on the API (which is the value that ends up being used in production) from openverse.org to api.openverse.engineering. The BASE_URL value is used in media reports to construct the item URL, and was constructing an incorrect URL which had the path components of the API but pointed to the frontend. Since this is a computed field, simply deploying this change should correct all the links provided on each of those tables.

Testing Instructions

  1. Set BASE_URL=https://openverse.org/ in your api/.env file
  2. Run just api/init to start the API
  3. Run API_URL=http://localhost:50270 just frontend/run dev:only to start the frontend
  4. Navigate to an image result on the frontend, and submit a report
  5. Visit http://localhost:50280/admin/api/imagereport/ and observe that the URL shows up as https://openverse.org/<api-media-url>, which is incorrect
  6. Change the api/.env value to be BASE_URL=http://localhost:50280/, restart the API, and visit the above page to observe the difference

Checklist

  • My pull request has a descriptive title (not a vague title likeUpdate index.md).
  • My pull request targets the default branch of the repository (main) or a parent feature branch.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added or updated tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible errors.
  • I ran the DAG documentation generator (if applicable).

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@AetherUnbound AetherUnbound requested a review from a team as a code owner February 16, 2024 23:59
@AetherUnbound AetherUnbound changed the title Use correct BASE_URL for the API Use correct BASE_URL for the API by default Feb 16, 2024
@github-actions github-actions bot added the 🧱 stack: api Related to the Django API label Feb 17, 2024
@openverse-bot openverse-bot added 🟨 priority: medium Not blocking but should be addressed soon 🛠 goal: fix Bug fix 💻 aspect: code Concerns the software code in the repository labels Feb 17, 2024
Copy link
Copy Markdown
Collaborator

@sarayourfriend sarayourfriend left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One to keep in mind for when we switch things over!

Copy link
Copy Markdown
Collaborator

@stacimc stacimc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😅 Nice!

]

BASE_URL = config("BASE_URL", default="https://openverse.org/")
BASE_URL = config("BASE_URL", default="https://api.openverse.engineering/")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why this variable is here instead of inside the base.py file at the same level 🤔 A curious thing!

@AetherUnbound AetherUnbound merged commit 1212e00 into main Feb 20, 2024
@AetherUnbound AetherUnbound deleted the fix/base-url branch February 20, 2024 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💻 aspect: code Concerns the software code in the repository 🛠 goal: fix Bug fix 🟨 priority: medium Not blocking but should be addressed soon 🧱 stack: api Related to the Django API

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Link to reported media URL in API Admin is incorrect

5 participants